<?php

session_start();

$isError = isset($_SESSION['is_error']) ? $_SESSION['is_error'] :false;
$errorBag = isset($_SESSION['error_bag']) ? $_SESSION['error_bag'] : ['username' => '', 'password' => '', 'pwdConfirm' => ''];

if ($isError && !empty($errorBag)) {
	unset($_SESSION['is_error']);
	unset($_SESSION['error_bag']);
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>用户注册</title>
	<link rel="stylesheet" type="text/css" href="public/css/register.css">
</head>
<body>
	<div id="wrapper">
		<form method="post" action="action/register_handle.php">
			<div class="input">
				<label for="username">用户名</label>
				<input type="text" name="username" id="username" placeholder="请输入用户名">
			</div>
			<div class="row">
				<?php if ($isError) echo $errorBag['username'] ?>
			</div>
			<div class="input">
				<label for="password">密码</label>
				<input type="password" name="password" id="password" placeholder="请输入密码">
			</div>
			<div class="row">
				<?php if ($isError) echo $errorBag['password'] ?>
			</div>
			<div class="input">
				<label for="pwdConfirm">确认密码</label>
				<input type="password" name="pwdConfirm" id="pwdConfirm" placeholder="请再次输入密码">
			</div>
			<div class="row">
				<?php if ($isError) echo $errorBag['pwdConfirm'] ?>
			</div>
			<div class="row">
				
			</div>
			<div class="input">
				<input type="submit" value="注册" class="register">
			</div>
			<span class="login">
				<span>我已经注册过了，马上</span>
				<a href="login.php">登录</a>
			</span>
		</form>
	</div>
</body>
</html>